/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.notaria.guerrasalas.bc;

import com.notaria.guerrasalas.be.CompraVentaVehiculo;
import gob.satt.comun.jpa.Command;
import java.util.List;
import javax.persistence.EntityManager;
import oracle.toplink.essentials.config.HintValues;
import oracle.toplink.essentials.config.TopLinkQueryHints;

/**
 *
 * @author Administrator
 */
public class ListarCompraVentaVehiculoPorVehiculoCommand implements Command<List<CompraVentaVehiculo>>   {

    private String nroPlacaDUA;

    public ListarCompraVentaVehiculoPorVehiculoCommand(String nroPlacaDUA) {
        this.nroPlacaDUA = nroPlacaDUA;
    }

    @Override
    public List<CompraVentaVehiculo> execute(EntityManager em) throws Exception {
        List<CompraVentaVehiculo> lista = null;
        lista = (List<CompraVentaVehiculo>) em.createNamedQuery("CompraVentaVehiculo.findByVehiculo")
                .setParameter(1, nroPlacaDUA.toUpperCase() + "%")
                .setParameter(2, nroPlacaDUA.toUpperCase() + "%")
                .setHint(TopLinkQueryHints.REFRESH, HintValues.TRUE)
                .getResultList();
        return lista;
    }
}